﻿//----------------------------------------------------------------
// Desc: 
// Edit: ShowLong, http://blog.csdn.net/showlong
//
// Date Created: 2013-07-10
//
// Update Date : 
//
// Copyright (c) Fuel Game Engine (http://www.fge-engine.com), All rights reserved.
//
//----------------------------------------------------------------
#pragma once


#if FUEL_MODULE_UI
FINLINE bool FUI_EventTransmit(FINPUT_PACKAGE& ipk, FUI_System* sys, fuPoint& cur)
{
    switch (ipk.nType)
    {
    case eIT_MOUSEMOVE:
        return sys->InputEvent(eUIE_MOUSEMOVE, cur);
    case eIT_MOUSEWHEEL:
        return sys->InputEvent(eUIE_MOUSEWHEEL, cur, ipk.p1.v.b ? 1 : 0);
    case eIT_LBUTTON_DOWN:
        return sys->InputEvent(eUIE_LBUTTONDOWN, cur);
    case eIT_RBUTTON_DOWN:
        return sys->InputEvent(eUIE_RBUTTONDOWN, cur);
    case eIT_LBUTTON_UP:
        return sys->InputEvent(eUIE_LBUTTONUP, cur);
    case eIT_RBUTTON_UP:
        return sys->InputEvent(eUIE_RBUTTONUP, cur);
    case eIT_LBUTTON_DBCLICK:
        return sys->InputEvent(eUIE_LBUTTONDBLCLK, cur);
    case eIT_KEYDOWN:
        return sys->InputEvent(eUIE_KEYDOWN, cur, ipk.p1.v.ui);
    case eIT_KEYUP:
        return sys->InputEvent(eUIE_KEYUP, cur, ipk.p1.v.ui);
    case eIT_CHAR:
        return sys->InputEvent(eUIE_CHAR, cur, ipk.p1.v.ui);
    case eIT_ACTIVATE:
        return sys->InputEvent(eUIE_ACTIVATE, cur, ipk.p1.v.b ? 1 : 0);
    case eIT_SETCURSOR:
        return sys->InputEvent(eUIE_SETCURSOR, cur);
    };
    return false;
}
#endif

#if FUEL_MODULE_ENGINE
FINLINE bool FInputTransmitToUI(FINPUT_PACKAGE& ipk, IFEngine* f, FUI_System* sys)
{
    fuPoint pt(f->GetCursorX(), f->GetCursorY());
    return FUI_EventTransmit(ipk, sys, pt);
}
#endif